<template>
  <div class="hydj_box">
    <header-comm></header-comm>
    <div
      class="lfrz_head header_sele"
      :style="$parent.$parent.collapsed==false?'left: 10%':'left:80px'"
    >
      <div class="add_qy">
        <!-- <a-button type="primary" @click="adddj">添加等级</a-button> -->
      </div>
      <div>
        <!-- <div class="hydj" v-if="$store.state.tjwz">
          <hydjxg class="hydj_xgym"></hydjxg>
        </div>-->
        <!-- <div class="hydj" v-if="pricexg">
          <hypricexg class="hydj_xgym"></hypricexg>
        </div>-->
        <div class="seach">
          <a-input
            placeholder="请输入要查询的关键字"
            @change="search"
            v-model="keywords"
            style="width:250px;"
          />
        </div>
      </div>
    </div>
    <!-- 表格-================= -->
    <div class="bcg">
      <!-- <div class="hedlist">
        <div class="headbtn"></div>
      </div> -->
      <div class="glwz">
        <a-spin tip="加载中..." :spinning="lfrzflag">
          <a-table
            @change="handleChangelist"
            :loading="loading"
            :columns="columns"
            :pagination="pagination"
            :dataSource="data"
          >
           <template slot="content" slot-scope="text, record, index">
              <div style="text-align:left;">
                {{text}} 
              </div>
            </template>
            <template slot="ly" slot-scope="text, record, index">
              <div>
                {{text=='pc_client'?'电脑端':'移动端'}} 
              </div>
            </template>
            <!-- <template slot="Icon" slot-scope="text, record, index">
            <div><img class="vipimg" :src="axios.defaults.baseURL+'/huiyuan/upload/LevelIcon/'+text "/></div>
            </template>-->
            <template slot="operation" slot-scope="text, record, index">
              <div class="editable-row-operations">
                <a class="del" @click="()=>xiugai(record,record.key)">修改</a>
                <a class="del" @click="()=>price(record,record.key)">价格权限</a>
                <a-popconfirm
                  title="确定删除吗?"
                  class="del"
                  @confirm="() => onDelete(record,record.key)"
                >
                  <a href="javascript:;">删除</a>
                </a-popconfirm>
              </div>
            </template>
          </a-table>
        </a-spin>

        <!-- <div class="fot_z">注：注册用户会员等级为 “默认会员” 类型</div> -->
      </div>
    </div>
  </div>
</template>

<script>
import qs from "qs";
import headerComm from "../header-comm/header.vue";
// import hydjxg from "./hydjxg.vue";
// import hypricexg from "./hypricexg.vue";

const columns = [
  {
    title: "访问手机",
    dataIndex: "phone"
  },
  {
    title: "访问者",
    dataIndex: "lxr"
  },

  {
    title: "公司名称",
    dataIndex: "dwmc",
  },

  
  {
    title: "内容",
    dataIndex: "content",
    scopedSlots: { customRender: "content" },
    width:400

  },
  {
    title: "类型",
    dataIndex: "types"
  },
  {
    title: "来源",
    dataIndex: "ly",
    scopedSlots: { customRender: "ly" }

  },  {
    title: "访问时间",
    dataIndex: "zdrq"
  }
  
  //     {
  //     title: "允许寄售",
  //     dataIndex: "consign"
  //   },
  //   {
  //     title: "操作",
  //     dataIndex: "operation",
  //     scopedSlots: { customRender: "operation" }
  //   }
];

const data = [];
export default {
  data() {
    this.cacheData = data.map(item => ({ ...item }));
    return {
      data,
      pricexg: false,
      columns,
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0,
        current: 1
      },
      loading: true,
      selectedRowKeys: [],
      hydjlist: [],
      keywords: "",
      lfrzflag: false
    };
  },
  components: {
    headerComm
    // hydjxg,
    // hypricexg
  },
  methods: {
    search() {
      this.pagination.current = 1;
      this.handleChangelist(this.pagination);
    },
    //表格
    handleChangelist(pagination, khmc) {
      this.loading = false;
      this.lfrzflag = true;
      this.pagination.current = pagination.current;
      this.axios
        .post(
          "huiyuan/visitLogList.php",
          qs.stringify({
            page: this.pagination.current,
            pageSize: pagination.defaultPageSize,
            sqdwid: this.$store.state.bbl_sqdwid,
            keywords: this.keywords
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.lfrzflag = false;
            this.data = res.data.result.data;
            this.pagination.total = Number(res.data.result.total);
            this.loading = false;
            this.cacheData = this.data.map(item => ({
              ...item
            }));
            for (var i = 0; i < res.data.result.data.length; i++) {
              this.data[i].key = res.data.result.data[i].id_num;
            }
          } else {
            this.lfrzflag = false;

            this.data = [];
          }
        });
    }

    // xiugai(value, key) {

    //   this.hydjlist = value;
    //   this.$store.state.tjwz = true;
    //   this.$store.state.xiugaiflag = "123";

    // },

    //   price(value, key) {

    //   this.hydjlist = value;
    //   this.pricexg = !this.pricexg;

    // },
    //会员等级---删除
    // onDelete(value, key) {
    //   const dataSource = [...this.data];
    //   this.data = dataSource.filter(item => item.key !== key);
    //   this.axios
    //     .post(
    //       "huiyuan/memberLevelDelete.php",
    //       qs.stringify({ id_num: value.id_num })
    //     )
    //     .then(res => {

    //       if (res.data.code == 303) {
    //         this.$notification["success"]({
    //           message: "成功",
    //           description: res.data.msg
    //         });
    //       }
    //     });
    // },
    // adddj(value, key) {
    //   this.$store.state.tjwz = true;
    //   this.$store.state.xiugaiflag = "";
    // },
  },
  computed: {},
  created() {
    this.handleChangelist(this.pagination);
  }
};
</script>

<style lang='less' scoped>
.lfrz_head {
  text-align: right;
}
.hydj_box {
  // position: relative;

  .hydj {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999999;
    height: 930px;
    .hydj_xgym {
      position: absolute;
      width: 80%;
      left: 50%;
      transform: translateX(-50%);
    }
  }
  .vipimg {
    width: 50px;
    height: 50px;
  }
  .header_sele {
    position: absolute;
    top: 55px;
    left: 200px;
    z-index: 999;
    text-align: right;
    width: 90%;
    background-color: #fff;
    box-shadow: 5px 5px 5px #ccc;
    // height: 50px;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .seach {
      display: inline-block;
      .sele {
        position: relative;
        i {
          position: absolute;
          top: 10px;
          right: 8px;
        }
      }
    }
    .list_head {
      display: inline-block;
      .tit {
        font-size: 16px;
      }
      padding: 10px 15px;
      .fl_right {
        .margin {
          margin: 0 5px;
        }
        .xzl_btn:hover {
          border: 0 !important;
          color: #fff !important;
          background: #1890ff !important;
        }
      }
    }
  }

  .glwz {
    width: 98%;
    position: absolute;
    top: 147px;
    left: 1%;
    background-color: #fff;
    border: 1px solid #ccc;
    .het {
      width: 100%;
      text-align: left;
      padding: 20px;
    }
    .ant-table-thead > tr,
    .ant-table-tbody > tr {
      height: 50px !important;
    }
    .del {
    }
  }

  .ant-spin-nested-loading > div > .ant-spin {
    top: 100px !important;
  }
  .del {
    padding-right: 15px;
    color: #40a9ff;
    cursor: pointer;
  }
  .fot_z {
    position: absolute;
    bottom: 20px;
    left: 26px;
    color: #999;
  }
}
</style>
